#ifndef WIDTABLETIMESLICE_H_
#define WIDTABLETIMESLICE_H_

#define SYVIEW_TABLETS 1

#include "scHeader.h"
#include "FactoryView.h"
#include "WidSybilView.h"
#include "ui_widTableTimeSlice.h"

namespace sybilpm
{

class TransTableTimeSlice : public TransSybilView
{
	Q_DECLARE_TR_FUNCTIONS(TransTableTimeSlice)
public:
	virtual ~TransTableTimeSlice() {}
	virtual std::string getTechnicalName() const {return std::string("TableTimeSlice");}
	virtual QString getDisplayName() const {return tr("master data");}
	virtual QString getDescription() const {return tr("view and edit timelined identities at a given deadline");}
};

class WidTableTimeSlice : public WidSybilView
{
	Q_OBJECT
public:
	WidTableTimeSlice(QWidget * parent = 0);
	virtual ~WidTableTimeSlice();
	virtual int getViewId() const {return SYVIEW_TABLETS;};
public slots:
	virtual void dataChangedSl(unsigned long transactionId);
	virtual void dataMarkSl();
	void mouseTableSl(const QModelIndex & index);

private:
	enum WttsState
	{
		WTTS_INIT		=0,
		WTTS_ENTITIES	=1,
		WTTS_DATA		=2
	};
	void setInfoText();
	WttsState state;
	Ui::WidTableTimeSlice ui;
	PkType entity;
	bool blockSig;
private slots:
	void newIdentitySl();
	void correctSl();
	void identitiesChangedSl(int index);
};

namespace
{
WidSybilView * createTableTimeSlice(QWidget * parent) {return new WidTableTimeSlice(parent);}
TransSybilView * createTransTableTimeSlice() {return new TransTableTimeSlice();}
const bool inFactory(FactoryView::get()->addProduct(SYVIEW_TABLETS, createTableTimeSlice, createTransTableTimeSlice));
}
} // namespace sybilpm

#endif /*WIDTABLETIMESLICE_H_*/
